/**
*****************************************************************************
*
* Copyright (C) 2018 LAN-YOU(GuangZhou). All rights reserved
*
* @par Project:
*      TCU
*
* @par Module:
*      
* @par Usage Notes:
*      Define all IPC event types used by TCU
*
* @par Author:
*      
*
*****************************************************************************
*/

#ifndef __CONFIGURE_H__
#define __CONFIGURE_H__

//EV or Fuel
#define FUEL_VEHICLE 

//#define D_ECALL_FUNC		1

///da
#define D_USEINTERNET_REPLAE_ECM	0
#define D_SGMII_MASTER_MODE			1
#define D_GET_GPS_INFO_FROM_DA		0


#define DOUBLE_PKI 1

//<
#define DOUBLE_APN
#define PKI_TEST    1
#if 0

#ifndef PKI_TEST
#ifndef  DOUBLE_APN
#define CLOUD_SERVER_WEBSIT     "iotdev.dfmc.com.cn"
#define CLOUD_SERVER_IP_ADDR    "58.49.84.116"
#define CLOUD_SERVER_PORT       6551
#else
#define  CLOUD_SERVER_WEBSIT   "vitlink.venucia.com"
#define  CLOUD_SERVER_IP_ADDR  "192.168.6.3"
#define  CLOUD_SERVER_PORT     6504
#endif
#else
#ifndef  DOUBLE_APN
#define CLOUD_SERVER_WEBSIT     "testzhcstcu.szlanyou.com"
#define CLOUD_SERVER_IP_ADDR    "192.168.6.15"
#define CLOUD_SERVER_PORT       6524   //启辰
//jiangbf 20200618
//#define CLOUD_SERVER_PORT       6527  //日产

#else
#define  CLOUD_SERVER_WEBSIT   "iotdev.dfmc.com.cn"
#define  CLOUD_SERVER_IP_ADDR  "58.49.84.116"
#define  CLOUD_SERVER_PORT     6551
#endif
#endif


#endif

// #define  CLOUD_SERVER_WEBSIT   "iotdev.dfmc.com.cn"
// #define  CLOUD_SERVER_IP_ADDR  "58.49.84.116"
// #define  CLOUD_SERVER_PORT     6551

/* 测试环境 */
#define  CLOUD_SERVER_WEBSIT   "dcvptboxzh.dfmc.com.cn"
//#define  CLOUD_SERVER_IP_ADDR  "58.49.84.39"
#define  CLOUD_SERVER_PORT     6534





typedef unsigned char    U8;        /* Unsigned 8Bit datatype */
typedef char      S8;        /* Signed 8Bit datatype */

/* 16 bit data type */
typedef unsigned short   U16;       /* Unsigned 16Bit datatype */
typedef signed short     S16;       /* Signed 16Bit datatype */

/* 32 bit data type */
typedef unsigned long    U32;       /* Unsigned 32Bit datatype */
typedef signed long      S32;       /* Signed 32Bit datatype */

#define UINT16 uint16_t 
#define UINT32 uint32_t

typedef unsigned char UCHAR;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;


//#define  BOOL uint8_t

/* BEGIN: Added for PN:New national standard data storage solution by xlyan, 2021/7/22 */

typedef enum 
{
	PROTOCOL_SERVER_DFL         = 0x00,    // DFL
    PROTOCOL_SERVER_DFM         = 0x01,    // DFM
    PROTOCOL_SERVER_GOV         = 0x02,    // GOV
}PROTOCOL_TO_SERVER;

typedef enum
{
	DO_NOT_SEND					= 0x00,/* 不发送到后台 */
	SEND_SUCCESS				= 0x01,
	SEND_FAILED                 = 0x02,
	RESERVE						= 0x03,/* 保留 */
}DATA_SEND_STATUS;

typedef enum
{
	REPUSH_CONTINUE					= 0x00,/* 继续补发 */
	REPUSH_STOP						= 0x01,/* 停止补发 */
}REPUSH_STATUS;

#define DM_STORAGE_QUEUE_SIZE             (40)   //
#define DM_STORAGE_QUEUE_TRIGGER_SIZE     (30)
#define DM_STORAGE_QUEUE_TRIGGER_TIMEOUT  (10 * 60)  //10min 10*60
#define DM_STORAGE_DATA_FILE_MAX_NUM   100 //100
#define DM_STORAGE_DATA_FILE_MAX_SIZE  (1024 * 1024 * 2)  //2MB 1024*1024*2

#define PackageFixLen       25
#define RepushNumerMin   1	   /*待回复补发数据最小数 */
#define RepushNumerMAX   300  /*待回复补发数据最大数 */

#define GbStorySizeMax	  22

#define DM_DATA_MAX_LENGTH    1000    //最大数据长度
//#define DM_INDEX_FILE_SINGLE_FIME_MAX_POISION_NUM    10000   //单个数据存储文件可以有多少个数据位置

#define DM_RESEND_FAIL_DELEY_TIME  (10 * 60)  //10min 10*60

#define TARGZ
#ifdef TARGZ
#define DM_ZIPFILE_EXTENSION_NAME  "tar.gz"
#else
#define DM_ZIPFILE_EXTENSION_NAME  "tar.bz2"
#endif

//storage data directory
#define DM_DATA_STORAGE_FILE_DIRECTORY_OLD_0418           "/oemdata/gbdatafolder"
#define DM_DATA_STORAGE_FILE_DIRECTORY           "/emmc/logs/gbdatafolder"
#define DM_DATA_INDEX_FILE_NAME    		  DM_DATA_STORAGE_FILE_DIRECTORY"/indexfile"



//resend data directory
#define DM_RESEND_DATA_FILE_DIRECTORY     DM_DATA_STORAGE_FILE_DIRECTORY"/resendfolder"
#define DM_DATA_RESEND_INDEX_FILE_NAME    DM_RESEND_DATA_FILE_DIRECTORY"/indexfile"


//temporary index file
#define DM_TEMP_FILE_NAME    			  DM_DATA_STORAGE_FILE_DIRECTORY"/tempindexfile"


#if (DM_STORAGE_QUEUE_TRIGGER_SIZE > DM_STORAGE_QUEUE_SIZE)
#error "Error: DM_STORAGE_QUEUE_SIZE must be larger than DM_STORAGE_QUEUE_TRIGGER_SIZE!"
#endif

#if (DM_STORAGE_DATA_FILE_MAX_NUM > 255)
#error "Error: the maximum value of DM_STORAGE_DATA_FILE_MAX_NUM cannot exceed 255!"
#endif


typedef enum
{
	NOT_CONNECTED  			= 0x00,
	CONNECTED_NOT_LOGIN     = 0x01,
	LOGIN_SUCCESS 			= 0x02,
	ABNORMAL				= 0xFF,
}SERVER_STATUS;
typedef struct Gb_DAGpsData{
	 unsigned int location_status; 
     unsigned int longitude; 
     unsigned int latitude; 
     unsigned int speed; 
     unsigned int direction ;
	
}S_GbDAGpsData,*PS_GbDAGpsData;



#define TCU_MSG_KEY             0x1234
#define TCU_HELPER_SETFLAG      0x8000
#define TCU_HELPER_MASK         0x7F00
#define TCU_HELPER_APP          0x0100
#define TCU_HELPER_DEVICE       0x0200
#define TCU_HELPER_LOG          0x0300
#define TCU_HELPER_TSP          0x0400
#define TCU_HELPER_WIFI         0x0500

typedef enum 
{
   	 //APP
	GET_4G_VER 					= 0x0101,
	GET_4G_VIN 					= 0x0102,
	GET_REASON 				    = 0x0103,
	GET_REBOOT 				    = 0x0104,

	//mcu command
	GET_MCU_INFO   				=  0x0201,
	GET_UART_INFO  				=  0x0202,

	SET_TEST_INFO               =  0x0203,
	SET_TCU_DIAGN_TEST          =  0x0204,
	SET_TCU_WARRING_SEND        =  0x0208,//TSP测试
	SET_TCU_NDS_TEST 			=  0x0209,
	SET_TCU_SGMII_TEST 			=  0x020a,
	SET_TCU_VCALL_NUM 		    =  0x020b,
	SET_TCU_VCALL  				=  0x020c,
	SET_TCU_ATC_SEND  			=  0x020d,
	SET_TCU_AUDIO_PLAY_TEST 	=  0x020e,
	SET_TCU_MSG_SEND 		    =  0x020f,
	SET_TCU_VIN_TEST            =  0x0210,
	SET_TCU_NAD_REBOOT          =  0x0250,

	SET_TCU_MCUDEBUG_SEND        =  0x0260,//MCU测试
	//4G module command
	GET_5G_INFO	    			=  0X0211,
	GET_DTC_INFO     			=  0x0212,
	GET_MODULE_STATE 			=  0x0213,
	GET_TSP_INFO  				=  0x0214,

	SET_TCU_DNS_RESOLV_TEST	 	=  0x0215,
	SET_TCU_ARP_TEST 			=  0x0216,
	//DA command
	GET_DA_INFO      			=  0X0221,
	SET_SGMII_WORK_MODE 		=  0x0222,
	//all  info
	GET_ALL_INFO     			=  0X0231,

	//LOG
	GET_LOG_LEVEL 				= 0x0301,
	SET_LOG_LEVEL 				= 0x0301 | TCU_HELPER_SETFLAG,
	GET_LOG_TAG 				= 0x0302,
	SET_LOG_TAG 				= 0x0302 | TCU_HELPER_SETFLAG,
	GET_LOG_FILTER 				= 0x0303,
	SET_LOG_FILTER 				= 0x0303 | TCU_HELPER_SETFLAG,
	GET_LOG_SWITCH				= 0x0304,
	SET_LOG_SWITCH 				= 0x0304 | TCU_HELPER_SETFLAG,
	//TSP
	GET_TSP_CONNSTATE			= 0x0401,
	SET_TSP_CONNSTATE 			= 0x0401 | TCU_HELPER_SETFLAG,
	GET_TSP_ADDR_AND_PORT 	    = 0x0402,
	SET_TSP_ADDR_AND_PORT 	    = 0x0402 | TCU_HELPER_SETFLAG,

	//pki chance
	GET_PKI_ENVIRONMENT	        = 0x0403,
	SET_PKI_ENVIRONMENT 	    = 0x0403 | TCU_HELPER_SETFLAG,

	//WIFI
	GET_WIFI_STATE 				= 0x0501,
	SET_WIFI_STATE 				= 0x0501 | TCU_HELPER_SETFLAG,
	GET_WIFI_SSID_AND_PASSWD 	= 0x0502,
	SET_WIFI_SSID_AND_PASSWD 	= 0x0502 | TCU_HELPER_SETFLAG,
	SET_WIFI_SSID 				= 0x0503 | TCU_HELPER_SETFLAG,



}E_CmdId;


typedef enum
{
	OE_RAT_1G = 1,
	OE_RAT_2G,
	OE_RAT_3G,
	OE_RAT_4G,
	OE_RAT_5G,
	OE_RAT_UNKNOW,
}NetworkMode;

typedef enum {
	ANTENNA_NORMAL   = 0,
	ANTENNA_SHORTED	 =1,
	ANTENNA_SHORTED_VCC	 = 2,
	ANTENNA_OPEN	 = 3,
	ANTENNA_UNKNOW   = 0xfe,
	
}AntennaState;
typedef enum
{
	OE_SIM_INSERT = 1,
	OE_SIM_REMOVED = 2,
	OE_SIM_UNLOCK = 3,
    OE_SIM_LOCK = 4,
    OE_SIM_BUSY = 5,
	OE_SIM_STATE_UNKNOWN =6,
}oe_sim_States_t;



#define YyPfClose(pipeFile) do { \
                        if(pipeFile) { \
                            pclose(pipeFile); \
                            pipeFile = NULL; \
                        } \
                     }while(0)
#define YyFree(addr) do { \
                        if(addr) { \
                            free(addr); \
                            addr = NULL; \
                        } \
                       }while(0)


typedef enum
{
	PUBLIC_INDEX = 1,
	PRIVATE_INDEX = 0,
	APNALL=2,
}APN_INDEX;

#define TAG_NONE "none"


typedef struct
{
    char serverAddr[128];///apollo.190325  [32];
     int serverPort;
  
}S_TspAddrAndPort, *PS_TspAddrAndPort;

typedef enum FlashNetStatus{
    FLASH_SUCESS    = 0,
    START_FLASH_NET = 1,
    FLASH_FAILURE   = 2,
}E_FlashNetStatus;

//jiangbf 20200724 for double pki
typedef enum Pki_Environment{
	PKI_TEST_ENVIRONMENT     = 0,
	PKI_BUSINESS_ENVIRONMENT = 1,
	PKI_UNKNOW_ENVIRONMENT   = 2,
}E_Pki_Environment;

typedef struct
{
    char serverAddr[128];///apollo.190325  [32];
    int serverPort;
	E_Pki_Environment ePkiEnvironment;
  
}S_pkiAddrAndPort;

#define DEFAULT_PKIENVIRONMENT PKI_BUSINESS_ENVIRONMENT


#define 	D_VCALL_SMS_NUM_MAX	20

#define D_EMC_MODE_NO_CNT_TSP	0///1

#if D_USEINTERNET_REPLAE_ECM
#define D_DA_SOME_IP_UP_TERSTER	1
#define D_PHY_AUTO_RECOVERY		1
#endif
#define D_DEBUG_MODE   0//	1
#define AUTO_REFLASH_NET	0///1
#if AUTO_REFLASH_NET==0
#define MANUAL_REFLASH_NET	1
#endif

#endif


